package com.henu.tanhang;

import android.app.Activity;
import android.app.Application;
import android.content.Context;

import com.baidu.mapapi.SDKInitializer;
import com.henu.tanhang.manager.LocationManager;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by th on 2017/5/18.
 */
public class ApplicationHenu extends Application {

    private List<Activity> activityList = new LinkedList<Activity>();
    private static ApplicationHenu instance;

    // 单例模式获取唯一的ApplicationHenu
    public static ApplicationHenu getInstance() {
        if (null == instance) {
            instance = new ApplicationHenu();
        }
        return instance;
    }
    public void addActivity(Activity activity) {activityList.add(activity);}
    public void exit() {for (Activity activity : activityList) {activity.finish();}}
    @Override
    public void onCreate() {
        super.onCreate();
        Context context = getApplicationContext();
        SDKInitializer.initialize(context);
        //默认参数
        ImageLoaderConfiguration configuration = ImageLoaderConfiguration.createDefault(this);
        com.nostra13.universalimageloader.core.ImageLoader.getInstance().init(configuration);
        LocationManager.getInstance(getApplicationContext());
        ImageLoader.getInstance().init(configuration);
    }
}
